From 12253498727cdecf204d2e87336f23dde9ab9494 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 29 Oct 2010 13:56:57 +0000 Subject: [PATCH] Add aviation units to KML writer. --- gpsbabel/defs.h | 3 ++- gpsbabel/kml.c | 5 +++-- gpsbabel/units.c | 4 ++++ gpsbabel/xmldoc/formats/options/kml-units.xml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index f3ef4f81f..841caaf30 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -1021,7 +1021,8 @@ typedef enum { units_unknown = 0, units_statute = 1, units_metric = 2, - units_nautical =3 + units_nautical =3, + units_aviation =4 } fmt_units; int fmt_setunits(fmt_units); diff --git a/gpsbabel/kml.c b/gpsbabel/kml.c index 5404440de..62b0667db 100644 --- a/gpsbabel/kml.c +++ b/gpsbabel/kml.c @@ -130,7 +130,7 @@ arglist_t kml_args[] = { "Indicate direction of travel in track icons (default = 0)", "0", ARGTYPE_BOOL, ARG_NOMINMAX }, {"units", &opt_units, - "Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical)", + "Units used when writing comments ('s'tatute, 'm'etric,' 'n'autical, 'a'viation)", "s", ARGTYPE_STRING, ARG_NOMINMAX }, {"labels", &opt_labels, "Display labels on track and routepoints (default = 1)", @@ -336,7 +336,8 @@ kml_wr_init(const char *fname) case 's': fmt_setunits(units_statute); break; case 'm': fmt_setunits(units_metric); break; case 'n': fmt_setunits(units_nautical); break; - default: fatal("Units argument '%s' should be 's' for statute units or 'm' for metric.", opt_units); break; + case 'a': fmt_setunits(units_aviation); break; + default: fatal("Units argument '%s' should be 's' for statute units, 'm' for metric, 'n' for nautical or 'a' for aviation.\n", opt_units); break; } /* * Reduce race conditions with network read link. diff --git a/gpsbabel/units.c b/gpsbabel/units.c index f75ce1338..2938bfa1f 100644 --- a/gpsbabel/units.c +++ b/gpsbabel/units.c @@ -30,6 +30,7 @@ fmt_setunits(fmt_units u) case units_statute: case units_metric: case units_nautical: + case units_aviation: units = u; return 0; default: @@ -53,6 +54,7 @@ fmt_distance(const double distance_meters, char **tag) } break; case units_nautical: + case units_aviation: d = METERS_TO_NMILES(distance_meters); *tag = "NM"; break; @@ -81,6 +83,7 @@ fmt_altitude(const double distance_meters, char **tag) switch (units) { case units_statute: + case units_aviation: d = METERS_TO_FEET(distance_meters); *tag = "ft"; break; @@ -112,6 +115,7 @@ fmt_speed(const double distance_meters_sec, char **tag) *tag = "mph"; break; case units_nautical: + case units_aviation: d = METERS_TO_NMILES(distance_meters_sec) * SECONDS_PER_HOUR ; *tag = "knts"; break; diff --git a/gpsbabel/xmldoc/formats/options/kml-units.xml b/gpsbabel/xmldoc/formats/options/kml-units.xml index 6d7a59578..733e74bb8 100644 --- a/gpsbabel/xmldoc/formats/options/kml-units.xml +++ b/gpsbabel/xmldoc/formats/options/kml-units.xml @@ -1,5 +1,5 @@ Units is a simple option. Specify 's' for "statute" (miles, feet, and other things that don't sensibly convert to each other, but are craved -by Americans) or 'm' for "metric". Default is 's'. +by Americans), 'm' for "metric", 'n' for "nautical" or 'a' for "aviation". Default is 's'. -- 2.30.2